﻿<div id="formChangePassword" class="form-horizontal">
    <div class="form-group">
        <label for="oldPassword" class="col-sm-2 control-label">原登录密码</label>
        <div class="col-sm-10">
            <input type="password" class="form-control" id="oldPassword" name="oldPassword" placeholder="请输入原登录密码">
        </div>
    </div>
    <div class="form-group">
        <label for="newPassword" class="col-sm-2 control-label">新密码</label>
        <div class="col-sm-10">
            <input type="password" class="form-control" id="newPassword" name="newPassword" placeholder="请输入新密码">
        </div>
    </div>
    <div class="form-group">
        <label for="newPassword1" class="col-sm-2 control-label">再输入新密码</label>
        <div class="col-sm-10">
            <input type="password" class="form-control" id="newPassword1" name="newPassword1" placeholder="请再输入新密码">
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="button" class="btn btn-primary" onclick="changePassword(this)" data-loading-text="修改中...">修改密码</button>
            <div id="message"></div>
        </div>
    </div>
</div>
<script src="~/static/js/jquery.md5.js"></script>
<script type="text/javascript">
    function changePassword(obj) {
        var oldPassword = $.trim($('#oldPassword').val());
        var newPassword = $.trim($('#newPassword').val());
        var newPassword1 = $.trim($('#newPassword1').val());
        var param = {
            OldPassword: oldPassword == '' ? '' : $.md5(oldPassword),
            NewPassword: newPassword == '' ? '' : $.md5(newPassword),
            NewPassword1: newPassword1 == '' ? '' : $.md5(newPassword1)
        };

        $(obj).button('loading');
        $.post('@Url.ToAjax(AjaxRequestType.Profile_ChangePassword)', {
            param: JSON.stringify(param)
        }, function (data) {
            $(obj).button('reset');
            Message.handle(data, function () { $('#formChangePassword input').val(''); }, 'message');
        });
    }
</script>
